<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:import href="/livcos.org/sys/resolver.xsl"/>

  <xsl:variable name="basePath" select="substring-before(static-base-uri(), '/sys/resolver')"/>
  <xsl:variable name="dataPath" select="replace($basePath, '/[^/]+$', '/data')"/>
  
  <xsl:template match="uri[@ext = 'html']">
    <access scope="view" obj="{$basePath}/document">
      <param key="ref" value="{$dataPath}{substring-after(@path, $basePath)}/{@name}"/>
    </access>
  </xsl:template>

  <xsl:template match="uri[@ext = 'pdf']">
    <access scope="view" obj="{$basePath}/fo/{@ext}">
      <param key="ref" value="{$dataPath}{substring-after(@path, $basePath)}/{@name}"/>
    </access>
  </xsl:template>

  <!-- special views -->

  <xsl:template match="uri[@full = concat($basePath, '/Intro.html')]" priority="1">
    <access obj="{$basePath}/{@name}" scope="view"/>
  </xsl:template>
  
  <!-- map special paths -->

  <xsl:template match="uri[matches(@full, concat($basePath, '.*/image/'))]" priority="1">
    <access obj="{$dataPath}{substring-after(@path, $basePath)}/{@name}" scope="view"/>
  </xsl:template>

</xsl:stylesheet>
